import threading
from time import sleep
'''
线程可以共享全局变量

'''

money = 1000


def run1():
    global money
    for i in range(20):
        sleep(0.1)
        money -= 1


def run2():
    global money
    for i in range(200):
        money -= 1


if __name__ == '__main__':
    t1 = threading.Thread(target=run1)
    t2 = threading.Thread(target=run1)
    t3 = threading.Thread(target=run1)
    t4 = threading.Thread(target=run1)

    t1.start()
    t2.start()
    t3.start()
    t4.start()

    t1.join()
    t2.join()
    t3.join()
    t4.join()

    print(money)

    print('main 线程结束')
